package com.umeng.kaoti2;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.mvplibrary.mvplibrary.ui.activity.BaseActivity;
import com.google.android.material.tabs.TabLayout;
import com.umeng.kaoti2.adapter.FragmentAdapter;
import com.umeng.kaoti2.fragment.FirstFragment;
import com.umeng.kaoti2.fragment.FourFragment;
import com.umeng.kaoti2.fragment.ThreeFragment;
import com.umeng.kaoti2.fragment.TwoFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends BaseActivity {


    @BindView(R.id.view_vp)
    ViewPager viewVp;
    @BindView(R.id.tab)
    TabLayout tab;

    @Override
    protected void initData() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        ArrayList<String> titles = new ArrayList<>();

        FirstFragment firstFragment = new FirstFragment();
        TwoFragment twoFragment = new TwoFragment();
        ThreeFragment threeFragment = new ThreeFragment();
        FourFragment fourFragment = new FourFragment();

        fragments.add(firstFragment);
        fragments.add(twoFragment);
        fragments.add(threeFragment);
        fragments.add(fourFragment);

        titles.add("首页");
        titles.add("消息");
        titles.add("咨询");
        titles.add("我");

        FragmentAdapter fragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), fragments, titles);
        viewVp.setAdapter(fragmentAdapter);
        tab.setupWithViewPager(viewVp);
    }

    @Override
    protected int createLayoutId() {
        return R.layout.activity_main;
    }


}